#include "cuda_runtime.h"

__global__ void matmul(float* A, float* B, float* C, int N)
{
    __shared__ float blocka[32][32];
    __shared__ float blockb[32][32];

    int row = blockIdx.y*blockDim.y + threadIdx.y;
    int col = blockIdx.x*blockDim.x + threadIdx.x;
    float sum = 0.0;

    blocka[threadIdx.y][threadIdx.x] = A[32*row+threadIdx.x];
    blockb[threadIdx.y][threadIdx.x] = A[threadIdx.y*N+col];
    __syncthreads();
    for(int i = 0; i < 32; i++)
    {
        sum += blocka[threadIdx.y][i] * blockb[i][threadIdx.x];
    }
    C[row*N+col] = sum;
}


void cuinproduct(double* a, double* b, int num_mode, int num_field)
{

    float* Amn, Anm, Cnn;
    cudaMalloc((float**)&Cnn, sizeof(float)*num_mode*num_mode);
    cudaMalloc((float**)&Amn, sizeof(float)*num_mode*num_field);
    cudaMalloc((float**)&Anm, sizeof(float)*num_mode*num_field);
}